package com.ydcycloud.admin.service.impl;

import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.ydcycloud.admin.service.MessageSend;

@Service
public class MessageSendImpl implements MessageSend{

	@Resource
	private JmsTemplate jmsTemplate;
	
	@Override
	public void send(String destinationName, final com.smart.message.core.Message param) {
		jmsTemplate.send(destinationName, new MessageCreator() {
			@Override
			public Message createMessage(Session session) throws JMSException {
				Message m = session.createTextMessage(JSON.toJSONString(param));
				return m;
			}
		});
		
		
	}


}
